package com.wc.算法基础课.D第四讲数学知识.容斥原理.能被整除的数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/23 22:20
 * @description https://www.acwing.com/problem/content/892/
 */
public class Main {
    static int n, m;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int M = 20;
    static int[] p = new int[M];

    // 容斥原理
    //因为容斥原理，过程最多就是有这么多项 c[m][1] + c[m][2]+c[m][m] = (2 ^ m)  - 1
    //所以这里我们循环2^m次方项
    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
        }
        int res = 0;
        int bound = (int) Math.pow(2, m);
        for (int i = 1; i < bound; i++) {
            // t 当前乘积，cnt表示1的个数
            long t = 1, cnt = 0;
            for (int j = 0; j < m; j++) {
                if ((i >> j & 1) > 0) {
                    cnt++;
                    if (t * p[j] > n) {
                        t = -1;
                        break;
                    }
                    t *= p[j];
                }
            }
            if (t != -1) {
                if ((cnt & 1) == 1) res += n / t;
                else res -= n / t;
            }
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
